package com.prj.controller;

import com.prj.common.core.controller.BaseController;
import com.prj.common.core.domain.AjaxResult;
import com.prj.common.core.page.TableDataInfo;
import com.prj.domain.EmpWork;
import com.prj.service.IEmpWorkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/emp_work")
@Api(tags = "员工工作记录")
public class EmpWorkController extends BaseController {
    @Autowired
    public IEmpWorkService empWorkService;


    @ApiOperation(value = "查询列表数据")
    @GetMapping("/list")
    public TableDataInfo list(EmpWork empWork){
        startPage();
        List<EmpWork> empWorks = empWorkService.selectEmpWorkList(empWork);
        return getDataByPage(empWorks);
    }

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(empWorkService.selectEmpWorkById(id));
    }


    @ApiOperation(value = "添加列表页")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody EmpWork empWork){
        return toAjax(empWorkService.insertEmpWork(empWork));
    }


    @ApiOperation(value = "修改列表页")
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody EmpWork empWork){
        return toAjax(empWorkService.updateEmpWork(empWork));
    }



    @ApiOperation(value = "删除列表数据")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(empWorkService.deleteEmpWorkByIds(ids));
    }

}
